//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

#define MAX 20000
int x[MAX], y[MAX], n, i, j, k, l, s, a, b, c;
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	scanf("%d%d%d%d", &n, &a,&b,&c);
	memset(x,0,sizeof(x));
	n*=2;	
	for(i=0;i<a;++i){
		x[i]=1;
	}
	for(i=0, s=a+2, j=1;i<b;++i, j+=2, s+=2){
		for(l=j;l<s&&l<n;++l)++x[l];
	}
	for(i=0;i<n;++i){
		y[i]=x[i];
	}
	for(i=0, s=a+b*2+4, j=3;i<c;++i, j+=4, s+=4){
		++y[j];
		for(l=j+1, k=0;l<s&&l<n;++l,++k)y[l]+=x[k];
	}
	printf("%d ", y[n-1]);
	
	return 0;
}
